package com.school.entity;

//教师子类：继承Person
public class Teacher extends Person {
    //教师专属属性（private权限）
    private String teacherId;
    private Course taughtCourse; //所授课程

    //子类构造方法：调用父类构造
    public Teacher(String id, String name, String gender, String teacherId) {
        super(id, name, gender);
        this.teacherId = teacherId;
    }

    //绑定授课课程
    public void setTaughtCourse(Course taughtCourse) {
        this.taughtCourse = taughtCourse;
        if (taughtCourse != null) {
            taughtCourse.setTeacherName(super.name); //访问父类protected属性name
        }
    }

    //打印教师授课单
    @Override
    public void printWorksheet() {
        System.out.println("=== 教师授课单 ===");
        super.printBaseInfo();
        System.out.println("工号：" + this.teacherId);

        if (taughtCourse != null) {
            System.out.printf("授课课程：%s | 地点：%s | 时间：%s%n",
                    taughtCourse.getName(), taughtCourse.getLocation(), taughtCourse.getTime());
        } else {
            System.out.println("  暂未分配授课课程");
        }
        System.out.println("================\n");
    }

    // Getter：供system包访问授课课程
    public Course getTaughtCourse() {
        return taughtCourse;
    }
}